<template>
  <div class="app-container">
    <el-tabs v-model="currentTabName" @tab-click="handleClick">
      <el-tab-pane label="sql查询" name="DebugSql">
        <Sql v-if="currentTabName === 'DebugSql'" :rowData="rowData" />
      </el-tab-pane>
      <el-tab-pane label="标签日志" name="HistoryLog">
        <History v-if="currentTabName === 'HistoryLog'" @switch-tab="switchTab" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import Sql from './debugsql'
import History from './historylog'

export default {
  components: { Sql, History },
  data() {
    return {
      currentTabName: 'DebugSql',
      rowData: {}
    }
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event)
    },
    switchTab(targetTab,data) {
      this.rowData = data.row
      this.currentTabName = targetTab // 切换到指定标签页
    }
  },
  created() {
    const tag = this.$route.query.tag
    console.log(tag)
    if (tag) {
      this.currentTabName = tag
    }
  }
}
</script>